package com.qinghong.blog.controller;

import com.qinghong.blog.entity.UserAuth;
import com.qinghong.blog.service.IUserAuthService;
import com.qinghong.blog.vo.Result;
import com.qinghong.blog.vo.UserAuthParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "登录接口")
@RestController
public class LoginController {

    @Autowired
    private IUserAuthService userAuthService;

    @ApiOperation("登录之后返回token")
    @PostMapping("/login")
    public Result login(@RequestBody UserAuthParam userAuthParam, HttpServletRequest request){
        return userAuthService.login(userAuthParam.getUsername(),userAuthParam.getPassword(),request);
    }
}
